Another Date Macro
By Max Smith
Copyright (c) 1990 Apple Users' Group, Sydney
Republished from Applecations, a publication of the Apple Users' Group, Sydney, Australia.
Do you leave your "Apple" turned on for most of the time? If you do and you use "Appleworks with Timeout Ultramacros" you will have found that Prodos only reads the date once at boot up and the Date macros will only provide the date that the system was booted up. There have been several macros presented to try and overcome the problem, most requiring manual input of the date at each session, I have not seen any as yet that provide the current date automatically (provided you have a clock card).
After looking at the Macro that Bernie Benson came up with on page 11 of "Applecations" May 1989, for an Australian date system I decided to advance one step further and present a Macro that would:
(a) Read the current date into Prodos and
(b) Print the date in Australian format to screen.
As Bernie had already carried out (b) it only left me with (a) and after much book searching, learning and annoying friends I came up with the following two macros which can be renamed to suit your own system.
The Macros
start
T:<all><ba-D : $1 = date : $2 = right $1, 4 : $3 = date2 : $4 = left $3, 5 : $5 = right $4, 2 : $6 = left $4, 2 : M = val $6 : X = 5 : if M = 1 then Z = 7 : else : if M = 2 then Z = 8 : else : if M = 3 then Z = X : else : if M = 4 then Z = X : else : if M = X then Z = 3 : else : if M = 6 then Z = 4 : else : if M = 7 then Z = 4 : else : if M = 8 then Z = 6 : else : if M = 9 then Z = 9 : else : if M = 10 then Z = 7 : else : if M = 11 then Z = 8 : else : if M = 12 then Z = 8 : elseoff : $8 = left $1, Z : C = val $5 : $9 = "th" : if C = 1 then $9 = "st" : else : if C = 31 then $9 = "st" : else : if C = 2 then $9 = "nd" : else : if C = 22 then $9 = "nd" : else : if C = 3 then $9 = "rd" : else : if C = 23 then $9 = "rd" : elseoff : $1 = str$ C + $9 + " " + $8 + " " + $2 : print $1>!
<ba-D>:<all><poke 255, 1 : call 51187 : M = peek 253 : D = peek 252 : Y = peek 254 : if M < 10 then poke 3870, 48 : poke 3871, M + 48 : else : poke 3870, M / 10 + 48 : Z = M / 10 * 10 : poke 3871, M - Z + 48 : elseoff : if D < 10 then poke 3873, 48 : poke 3874, D + 48 : else : poke 3873, D / 10 + 48 : Z = D / 10 * 10 : poke 3874, D - Z + 48 : elseoff : poke 3876, Y / 10 + 48 : Z = Y / 10 * 10 : poke 3877, Y - Z + 48>!
Briefly how it works
By calling "Solid Apple - T" from within Appleworks the macro first calls macro <both apple - d> which reads the current date from my "Overdrive" clock card in slot 7 to the correct location in Prodos in RAM, <ba-d> then hands control back to the first macro, <T> which then uses the <date> and <date2> reserved macros to print the date in Australian format at the cursor location, this can be used in any of the applications.
A benefit of using two macros instead of one, you are able to use the <ba-d> from the keyboard at the beginning of each day of a continuing Appleworks session, (there will not be any visible response) and the use of <date> or <date2> macros will then yield the correct date if you don't want the Australian format. However there is nothing to stop you having the whole lot in one macro.
Problems
If it does not work for you then your clock address is probably different. [Sub-editor's note: You must have an "Overdrive" clock card.] If your clock card is in another slot you may only need to change :call 51187: which in Hex is $C7F3 and the 7 is the slot number. The following are the codes for different slots:
Slot No. call Hex or call Decimal
2 $C2F3 49907
3 $C3F3 50163
4 $C4F3 50419
5 $C5F3 50675
6 $C6F3 50931
7 $C7F3 51187
The call statement can be either Hex or Decimal, however if you write the macro with Hex you will find that when it is compiled and saved to Ultra.System, next time you call the macro to desktop it will have converted to Decimal but it will still work properly, and if you are just learning like I am you may wonder what is going on.
This Macro will not work with Super Macroworks as it does not accept the range of commands available in Ultramacros.
If you would like a working copy of my macro file just send me a note with a disk and return postage and its yours for the asking.
P.S. My thanks to Bernie Bensen for his part in this.
Max Smith
191 Nicholson St
Goulburn 2580

THIS CONTENT COPYRIGHT © 2007, APPLE MACINTOSH USERS' GROUP, SYDNEY
Permission has been obtained to make this material available on the Internet.

Permission is hereby granted for non-profit user groups to republish this content.
PLEASE CREDIT THE AUTHOR AND THE SOURCE: Applecations, publication of the Apple Users' Group, Sydney, Australia

THIS PAGE COPYRIGHT © 2007, ANDREW ROUGHAN